<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use DB;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    //首页控制器
    public function index()
    {   
        //
        // function getIp()

        // {

        //      if(!empty($_SERVER['HTTP_CLIENT_IP'])){

        //           return $_SERVER['HTTP_CLIENT_IP'] ;

        //      }elseif(!empty ($_SERVER['HTTP_X_FORVARDED_FOR'])){

        //           return $_SERVER['HTTP_X_FORVARDED_FOR'];

        //      }elseif(!empty($_SERVER['REMOTE_ADDR'])){

        //           return $_SERVER['REMOTE_ADDR'];

        //      }else{

        //           return "未知IP";

        //      }
        // }

        //$ip = $_SERVER['REMOTE_ADDR'];
        $ip = $_SERVER['HTTP_CLIENT_IP'];

        //dd(getIp());
        dd($ip);
        //遍历商品数据
        $gresult=DB::table('goods')
        ->get();
        //遍历前台导航数据
        $cresult=DB::table('category')
        ->get();
        //dd($cresult);

        //遍历前台小方块数据

        //遍历轮播数据
        $presult=DB::table('player')
        ->select('cid','name','img')
        ->where('status','1')
        ->get();
        //dd($presult);

        //返回首页试图模板并分配数据
        return view('/Home/Index',['cresult'=>$cresult,'presult'=>$presult,'gresult'=>$gresult]);
    } 
}
